package top.techqi.view.recyclerview.tile

import android.view.LayoutInflater
import android.view.ViewGroup

abstract class TilePortion<VH : TileHolder<R>, R : TileRecord> {
    open val viewType: Int = this::class.java.hashCode()

    abstract fun onMakeHolder(inflater: LayoutInflater, container: ViewGroup): VH

    abstract fun onBindRecord(holder: VH, record: R)

    open fun onBindRecord(holder: VH, record: R, payloads: List<Any>) {
        onBindRecord(holder, record)
    }

    open fun onAttached(holder: VH) = Unit

    open fun onDetached(holder: VH) = Unit

    open fun diffPayload(oldRecord: R, newRecord: R): Any? = null
}
